<?php

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

require_once libfile('function/core');
require_once libfile('function/date');
require_once libfile('function/database');
require_once libfile('function/vote');

$aid = intval(getgpc('aid'));
$uid = intval(getgpc('uid'));
if (!empty($aid)) {
	$activity = get_activity($aid);
}
if (empty($uid) || $uid == 0){
	$uid = $_G['uid'];
}
if (!empty($uid) && $uid != 0){
	$remainder_gold_coin = get_gold_coin();
	$sql = ' select *, unix_timestamp() as cache_time from '.DB::table('vote_user').' where uid = '.$uid;
	if (!empty($aid)) {
		$sql .= ' and aid ='.$aid;
	}
	$sql .= ' limit 1';
	$users = query($sql);
	get_user_count($users);
	$user = $users[0];
	if (empty($aid)) {
		$aid = $user['aid'];
		$activity = get_activity($aid);
	}

	if (!empty($user)) {
		if ($user['picid'] > 0) {
			$pic = DB::fetch_first(' select * from '.DB::table('home_pic').' where picid = '.$user['picid']);
			include_once template("bid/user");
		}
		else {
			require_once "bid.php?&mod=setimg&aid=$aid&uid=$uid";
		}
	}
}
else {
	showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
}

?>